<template>
	<view class="wpprs">
		<view class="title">UPU Lab</view>
		<view class="calendar"><ren-calendar ref="ren" :markDays="markDays" :headerBar="true" @onDayClick="onDayClick"></ren-calendar></view>
		<scroll-view class="scrollbox" scroll-y>
			<imgEmpty v-if="engineerPendingList.length == 0"></imgEmpty>
			<view class="list" v-for="(item, idx) in engineerPendingList" :key="idx">
				<view class="title">{{ typeList[item.type] }}申请</view>
				<view class="ctns"><listItem :item="item" @workOrderAccept="workOrderAccept"></listItem></view>
			</view>
		</scroll-view>
	</view>
</template>
idx
<script>
import { calendar, engineerPending } from '../../api/home';
import { workOrderAccept } from '../../api/order';
import imgEmpty from '../../components/imgEmpty.vue';
import listItem from '../../components/listItem.vue';
import { setTabBarBadge } from '@/utlis/other.js';
export default {
	components: { listItem, imgEmpty },
	data() {
		return {
			curDate: '',
			markDays: [],
			engineerPendingList: [],
			timerText: '',
			typeList: {
				1: '安装',
				2: '报修',
				3: '巡检',
				4: '续保',
				5: '校验',
				6: '验证',
				7: '培训',
				8: '移机'
			}
		};
	},
	onReady() {
		this.onDayClick(this.$refs.ren.getToday());
		calendar().then((data) => {
			if (data.content && data.content.length != 0) {
				data.content.forEach((item) => {
					this.markDays.push(item.date);
				});
			}
			this.calendarList = data.content;
			// console.log('calendar',data);
		});
	},
	onShow() {
		this.subscriptionsMsg();
	},
	methods: {
		workOrderAccept(orderid) {
			if (!orderid) {
				return;
			}
			workOrderAccept(orderid).then((data) => {
				uni.showToast({
					title: '接单成功',
					duration: 2000
				});
				setTabBarBadge(0, false);
				this.onDayClick({ date: this.timerText });
			});
		},
		onDayClick(val) {
			this.timerText = val.date;
			engineerPending({ date: new Date(val.date + `${' '}00:00:00`).getTime() }).then((data) => {
				this.engineerPendingList = data.content;
			});
		}
	}
};
</script>

<style lang="less" scoped>
.wpprs {
	background: url('https://junminyiqi.oss-cn-shanghai.aliyuncs.com/flies/d29eccf2-f7be-dbc8-4853-e3b19055825b.png');
	background-repeat: no-repeat;
	background-size: 100%;
	min-height: 600upx;
	padding: 0upx 30upx;
	background-color: #f1f1f1;
	.title {
		font-size: 42upx;
		color: #fff;
		text-align: center;
		padding: 20upx;
	}
	.calendar {
		overflow: hidden;
		border-radius: 20upx;
		box-shadow: 0px 16px 32px 0px rgba(0, 0, 0, 0.05);
	}
	.scrollbox {
		padding: 20upx;
		box-sizing: border-box;
		.list {
			padding: 20upx;
			.title {
				border-left: 6upx red solid;
				padding-left: 20upx;
				line-height: 1;
				font-size: 32upx;
				font-weight: 500;
				margin-bottom: 20upx;
				color: #000;
				text-align: left;
			}
			.ctns {
				background-color: #fff;
				border-radius: 10upx;
			}
		}
	}
}
</style>
